#ifndef MYCONFIG_H
#define MYCONFIG_H

#include <QObject>
#include <QSettings>
#include <QDir>
#include <QFile>
#include <QVector>

typedef struct _WINDOW_CONFIG
{
    quint8 videoNum;            //视频路数 1 - 4
    QString resourcesName;      //视频资源名
    QString ip;                 //ip
    quint16 port;               //端口
    QString netCard;            //netcard
    int bindWay;                //udp接收绑定方式 1：单播 2：组播 3：广播

    _WINDOW_CONFIG() {
        videoNum = 0;
        resourcesName = "default";
        ip = "127.0.0.1";
        port = 1234;
        netCard = "eth0";
        bindWay = 1;
    }
    _WINDOW_CONFIG(quint8 num, QString name, QString ip_init,
                   quint16 port_out, QString netCard_out, int bindWay_out) {
        videoNum = num;
        resourcesName = name;
        ip = ip_init;
        port = port_out;
        netCard = netCard_out;
        bindWay = bindWay_out;
    }

    // 赋值运算符重载
    _WINDOW_CONFIG& operator=(const _WINDOW_CONFIG& other) {
        if (this != &other) {
            videoNum = other.videoNum;
            resourcesName = other.resourcesName;
            ip = other.ip;
            port = other.port;
            netCard = other.netCard;
            bindWay = other.bindWay;
        }
        return *this;
    }
}WINDOW_CONFIG, *P_WINDOW_CONFIG;

class MyConfig : public QObject
{
    Q_OBJECT
public:
    explicit MyConfig(QObject *parent = nullptr);


    void ensureConfigFolderAndFile();
    void initConfig(); //初始化配置文件
    void saveWindowConfigs(const QVector<WINDOW_CONFIG> &configs);
    QVector<WINDOW_CONFIG> loadWindowConfigs();

    QString m_dir;

signals:

};

#endif // MYCONFIG_H
